#ifndef CONTROL_H
#define CONTROL_H

#include <QtGui>
#include <QObject>
#include <QRect>
#include <QTime>

class Canvas;
class Snake;
class SaveWindow;
class AboutWindow;

class Game;
class GameData;

class Control : public QObject
{
    Q_OBJECT

public:
    Control(Canvas* c);
    void setup(int gw, int gh, int cl);
    void start();
    void setLabel(QLabel* l);
    void setPauseAct(QAction* act);
    int getCellLenght();
    void addEat();
    void controlKey(int key);
    void tooglePause();
    void about();
    void closeAllWindows();

public slots:
    void controlTime();

private:
    Canvas* canvas;
    Game* game;
    QLabel* label;
    QAction* pauseAct;
    int level;
    int scores;
    bool update;
    bool gameover;
    bool gamewin;
    bool pause;
    int grid_x;
    int grid_y;
    int cellLenght;
    QPoint eat;
    QTimer timer;
    AboutWindow* aboutWin;
    QString player;

    void moveSnake(int mov);
    void restartTime();
    void readSlotGames();
};

#endif // CONTROL_H
